#ifndef ITEMMODEL_H
#define ITEMMODEL_H



#include "models_global.h"
#include "ItemRoot.h"



#include <QAbstractItemModel>
#include <QPointer>



class MODELSSHARED_EXPORT ItemModel : public QAbstractItemModel
{
    Q_OBJECT

public:

    ItemModel(QObject* parent = 0);
    ItemModel(ItemRoot* root, QObject* parent = 0);

    virtual ~ItemModel();

    AbstractItem* indexItem(const QModelIndex& index) const;

    AbstractItem* rootItem() const;
    virtual void setRootItem(AbstractItem* root);

    virtual QModelIndex index(int row, int column, const QModelIndex &parent) const;
    virtual QModelIndex parent(const QModelIndex &child) const;
    virtual QModelIndex reference(const QModelIndex& ref) const;
    virtual QModelIndexList references(const QModelIndex& ref) const;

    virtual int rowCount(const QModelIndex &parent) const;
    virtual int columnCount(const QModelIndex &parent) const;

    virtual QVariant data(const QModelIndex &index, int role) const;
    virtual bool setData(const QModelIndex &index, const QVariant &value, int role);

    virtual QVariant headerData(int section, Qt::Orientation orientation, int role) const;

    virtual Qt::ItemFlags flags(const QModelIndex &index) const;

    virtual bool insertRows(int row, int count, const QModelIndex &parent);
    virtual bool removeRows(int row, int count, const QModelIndex &parent);

    bool insertRow(int row, const QModelIndex &parent);
    bool removeRow(int row, const QModelIndex &parent);


protected:


    QPointer<AbstractItem> m_root;


};



#endif // ITEMMODEL_H


